﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.SweptVolume.CCoSVSweptVolumeCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections;
using System.Resources;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.PrivateImplementationDetails;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.SweptVolume;

public class CCoSVSweptVolumeCmd : TxButtonCommand
{
  private bool m_dialogIsOpen;
  private CApSVSweptVolumeCmdEnabler m_enabler;

  public CCoSVSweptVolumeCmd()
  {
    this.m_dialogIsOpen = false;
    this.m_enabler = new CApSVSweptVolumeCmdEnabler();
  }

  public virtual void Execute(object cmdParams)
  {
    if (this.m_dialogIsOpen)
      return;
    if (!TxTcUtilities.IsTcAnyPlatform)
      this.CheckSweptVolumeCustomization();
    ((Control) new CuiSvMultipleOpSweptVolumeDlg(this)).Show();
  }

  public virtual string Category
  {
    get
    {
      return new ResourceManager("DnProcessSimulateCommands.SweptVolume.StringTable", ((object) this).GetType().Assembly).GetString("SV_CATEGORY");
    }
  }

  public virtual string Name
  {
    get
    {
      return new ResourceManager("DnProcessSimulateCommands.SweptVolume.StringTable", ((object) this).GetType().Assembly).GetString("SV_NAME");
    }
  }

  public virtual string Tooltip
  {
    get
    {
      return new ResourceManager("DnProcessSimulateCommands.SweptVolume.StringTable", ((object) this).GetType().Assembly).GetString("SV_TOOLTIP");
    }
  }

  public virtual string Description
  {
    get
    {
      return new ResourceManager("DnProcessSimulateCommands.SweptVolume.StringTable", ((object) this).GetType().Assembly).GetString("SV_DESCRIPTION");
    }
  }

  public virtual string Bitmap => "SweptVolume.SweptVolume.bmp";

  public virtual string LargeBitmap => "SweptVolume.SweptVolume_LARGE.png";

  public virtual ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this.m_enabler;

  public virtual ITxImage Image => (ITxImage) TxImageManager.GetImageByKey("SweptVolume");

  public void DialogIsOpen(bool dialogIsOpen) => this.m_dialogIsOpen = dialogIsOpen;

  private void CheckSweptVolumeCustomization()
  {
    if (this.HasFieldInCustForClass("SweptVolume", "clearance"))
      return;
    ResourceManager resourceManager = new ResourceManager("DnProcessSimulateCommands.SweptVolume.StringTable", ((object) this).GetType().Assembly);
    string str = resourceManager.GetString("SV_NAME");
    int num = (int) TxMessageBox.Show(resourceManager.GetString("SV_MISSING_CLEARANCE_CUSTOMIZATION_FIELD"), str, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  }

  private bool HasFieldInCustForClass(string className, string fieldName)
  {
    ArrayList allFields = TxApplication.ActiveDocument.PlatformGlobalServicesProvider.GetTypeMetaData(className).AllFields;
    bool flag = false;
    foreach (TxPlanningTypeFieldData planningTypeFieldData in allFields)
    {
      if (planningTypeFieldData.Name == fieldName)
        flag = true;
    }
    return flag;
  }

  public virtual bool Connect() => true;

  public virtual bool Licensed => TxCommandLicenser.SweptVolumeLicense;
}
